/*
 *  Copyright 2008 by Spectrum Digital Incorporated.
 *  All rights reserved. Property of Spectrum Digital Incorporated.
 */

/*
 *  DDR2 Test
 *
 */
#include "stdio.h"
#include "C6747.h"



void testallblock(void)
{

    Uint32 i;
	Uint32 temp;
    Uint32 *SDRAM_StartAdd;
	Uint32 *temp_add;
    Uint32 Length=0x1000000;
    //Uint32 Length=0x0000008;
    SDRAM_StartAdd = (Uint32 *)0xc0000000;
    



  	for(i=0;i<Length;i++)
	{
		temp_add = SDRAM_StartAdd+i;
		*(temp_add) = 0;	
	}
	
	for(i=0;i<Length;i++)
	{
		temp = *(SDRAM_StartAdd+i);
		if(temp != 0x00000000)
		{
			temp = *(SDRAM_StartAdd+i);
			printf("\nWhen writing 0x00000000, Address 0x%x is error!",i);
			SW_BREAKPOINT;
		}
	}
	printf("\nWriting 0x00000000 is ok.");
	
	for(i=0;i<Length;i++)
	{
		*(SDRAM_StartAdd+i) = 0xFFFFFFFF;
	}
	for(i=0;i<Length;i++)
	{
		if(*(SDRAM_StartAdd+i) != 0xFFFFFFFF)
		{
			printf("\nWhen writing 0xFFFFFFFF, Address 0x%x is error!",i);
			SW_BREAKPOINT;
		}	
	}
	printf("\nWriting 0xFFFFFFFF is ok.");
	
	for(i=0;i<Length;i++)
	{
		*(SDRAM_StartAdd+i) = 0xAAAAAAAA;
	}
	for(i=0;i<Length;i++)
	{
		if(*(SDRAM_StartAdd+i) != 0xAAAAAAAA)
		{
			printf("\nWhen writing 0xAAAAAAAA, Address 0x%x is error!",i);
			SW_BREAKPOINT;
		}	
	}
	printf("\nWriting 0xAAAAAAAA is ok.");
	
	for(i=0;i<Length;i++)
	{
		*(SDRAM_StartAdd+i) = 0x55555555;
	}
	for(i=0;i<Length;i++)
	{
		if(*(SDRAM_StartAdd+i) != 0x55555555)
		{
			printf("\nWhen writing 0x55555555, Address 0x%x is error!",i);
			SW_BREAKPOINT;
		}	
	}
	printf("\nWriting 0x55555555 is ok.");
	
	for(i=0;i<Length;i++)
	{
	//	*(SDRAM_StartAdd+i) = i;
		temp_add = SDRAM_StartAdd+i;
		*(temp_add) = i;
	}
	for(i=0;i<Length;i++)
	{
		if(*(SDRAM_StartAdd+i) != i)
		{
			printf("\nWhen writing sequence data, Address 0x%x is error!",i);
				 
		}	
	}
	
    printf("\nTesting is success.");

}

